package com.polaris.live.adapter

import com.polaris.live.R
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterBlockBinding
import com.polaris.live.im.sfs.bean.live.ext.UserBasicVo
import com.polaris.live.utils.CommonUtils
import com.polaris.live.widget.LevelView
import com.polaris.live.widget.avatar.FrameImageUtils

/**
 * BlockAdapter
 *
 * @author Created by 半仙 on 2023/9/4/004 12:03
 */
class BlockAdapter : BaseBindingAdapter<AdapterBlockBinding, UserBasicVo>() {

    init {
        addChildClickViewIds(R.id.block_ll, R.id.block_item_head)
    }

    override fun convert(holder: VBViewHolder<AdapterBlockBinding>, item: UserBasicVo) {
        holder.vb.apply {
            blockItemHead.setImageUrl(item.avatar)
            blockItemNickName.text = item.nickname
            avFv.setFrameImage(FrameImageUtils.urlToFrameImageBean(item.avatarFrame))
            if (CommonUtils.isMan(item.sex)) {
                lvView.setRichsLevel(item.richs, LevelView.LEVEL_VIEW_SMALL)
            } else {
                lvView.setCharmsLevel(item.charms, LevelView.LEVEL_VIEW_SMALL)
            }
            vipView.setVipLevel(item.vipLevel)
            blockItemCountry.setCountry(item.country)
        }
    }

}